<?php
    session_start();

    if (!isset($_SESSION['is_logged_in'])) {
        header("Location:../index.php");
        die();
    }
    
    ini_set('display_errors',"1");
    include("conexion.php");
    
    $strSQL = $_POST["strSQL"];
	$NumePart = $_POST["NumePart"];

	$conn = new mysqli($dbhost, $dbuser, $dbpass, $db) or die("Problemas al conectar con la BD");
	
	if ($NumePart == "@#@") {
		$strAux = "SELECT MAX(NumePart) NumePart FROM partidos";
		$tabla = $conn->query($strAux);

		$fila = $tabla->fetch_array();
		$NumePart = $fila["NumePart"];
		
		$strSQL = str_replace("@#@", $NumePart, $strSQL);
		
		$tabla->free();
	}
		
    //Separo en un array
    $sqlScripts = explode(";", $strSQL );
    
    for($i=0; $i<count($sqlScripts); $i++ ) {
    	$sqlScripts[$i] = trim($sqlScripts[$i]);
    	if ($sqlScripts[$i] != "")
    		$conn->query($sqlScripts[$i]);
    }
	
	$conn->close();
?>